package com.appkubes.mall.restful.application.statis.controller;

import com.appkubes.cloud.annotation.KylinPostMapping;
import com.appkubes.cloud.annotation.KylinRestController;
import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.restful.application.statis.entity.vo.PageViewEventVO;
import com.appkubes.mall.restful.event.event.EventService;
import com.appkubes.mall.restful.event.statis.PageViewStatisEvent;
import com.appkubes.mall.restful.event.statis.entity.PageViewEventEO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;

/**
 * @Author: Rongjie
 * @Date: 2020/3/6
 * @Description:
 */
@Slf4j
//@KylinRestController(value = "/statis/page", docs = "统计模块")
public class StatisPageController {
    @Resource
    EventService eventService;

    @KylinPostMapping(value = "/view", docs = "页面浏览")
    public Response view(@ParamValid PageViewEventVO pageViewVO) {
        PageViewEventEO pageViewEventEO = new PageViewEventEO();
        BeanUtils.copyProperties(pageViewVO, pageViewEventEO);
        PageViewStatisEvent event = new PageViewStatisEvent(this);
        event.setPageViewEventEO(pageViewEventEO);
        eventService.publishEvent(event);
        return Response.success();
    }

}
